<template>
  <div class="page-wrapper">
    <a-list :data-source="announceListData">
      <template #renderItem="{ item }">
        <div class="announce-item">
          <a-flex :style="{ marginBottom: '16px' }" align="center">
            <img
              src="/@/assets/images/h5/icon-announce.png"
              alt=""
              :style="{ marginRight: '5px' }"
            />
            <span class="announce-title">{{ item.title }}</span>
          </a-flex>
          <div class="announce-content" v-html="item.description"></div>
          <div class="announce-content">...</div>
          <a-flex :style="{ marginTop: '16px' }" justify="space-between" align="center">
            <div :style="{ color: '#A1A4AB', fontSize: '12px', lineHeight: '17px' }">
              {{ item.createTime }}
            </div>
            <div :style="{ color: '#fd436a' }" @click="handleTurnDetail(item)">立即查看&gt;</div>
          </a-flex>
        </div>
      </template>
    </a-list>
  </div>
</template>

<script>
import { defineComponent } from 'vue'
import request, { AxiosWrapper } from '@/utils/request'

export default defineComponent({
  data() {
    return {
      announceListData: [],
    }
  },
  mounted() {
    this.getAnnounceList()
  },
  methods: {
    async getAnnounceList() {
      try {
        const res = await request.get('/hd/appGonggao/list')
        this.announceListData = res.result.records
      } catch (error) {}
    },
    handleTurnDetail(item) {
      const token = AxiosWrapper.getHashSearchParam('token')
      this.$router.push(`/h5/announceDetail?token=${token}&id=${item.id}`)
    },
  },
})
</script>

<style lang="less" scoped>
.page-wrapper {
  height: 100%;
  overflow-y: auto;
  background-color: #f3f3f3;
}
.page-wrapper::-webkit-scrollbar {
  display: none;
}
.announce-item {
  margin: 16px;
  padding: 12px 20px;
  border-radius: 10px;
  background-color: #ffffff;
  .announce-title {
    font-size: 15px;
    line-height: 26px;
    font-weight: bolder;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #000000;
  }
  .announce-content {
    font-size: 12px;
    line-height: 16px;
    height: 16px;
    overflow: hidden;
  }
}
</style>
